# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=jinja

pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2.7.2
pkgrel=2
pkgdesc="A simple pythonic template language written in Python (mingw-w64)"
arch=('any')
license=('BSD')
url="http://jinja.pocoo.org/"
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python3-setuptools"
  "${MINGW_PACKAGE_PREFIX}-python3-markupsafe"
  "${MINGW_PACKAGE_PREFIX}-python2-setuptools"
  "${MINGW_PACKAGE_PREFIX}-python2-markupsafe"
)
source=(http://pypi.python.org/packages/source/J/Jinja2/Jinja2-$pkgver.tar.gz)
sha256sums=('310a35fbccac3af13ebf927297f871ac656b9da1d248b1fe6765affa71b53235')

build() {
  cd "$srcdir"
  rm -rf python{2,3}-build
  for builddir in python{2,3}-build; do
    cp -r Jinja2-$pkgver $builddir
    pushd $builddir
    ${MINGW_PREFIX}/bin/${builddir%-build} setup.py build
    popd
  done
}

package_python3-jinja() {
  pkgdesc='Python3 documentation generator'
  depends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools" "${MINGW_PACKAGE_PREFIX}-python3-markupsafe")

  cd "$srcdir/python3-build"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} --root="$pkgdir" -O1

  install -Dm644 LICENSE "${pkgdi}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}
 
package_python2-jinja() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools" "${MINGW_PACKAGE_PREFIX}-python2-markupsafe")

  cd "$srcdir/python3-build"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} --root="$pkgdir" -O1
    
  install -Dm644 LICENSE "${pkgdi}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE"
}

package_mingw-w64-i686-python2-jinja() {
  package_python2-jinja
}

package_mingw-w64-i686-python3-jinja() {
  package_python3-jinja
}

package_mingw-w64-x86_64-python2-jinja() {
  package_python2-jinja
}

package_mingw-w64-x86_64-python3-jinja() {
  package_python3-jinja
}
